package com.ksp.api.quartz;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.el.ArrayELResolver;
import javax.validation.constraints.Null;

import org.assertj.core.error.ShouldBeEqualToIgnoringFields;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.EnableLoadTimeWeaving;
import org.springframework.mail.MailParseException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.sun.tools.javac.file.BaseFileObject;

@Controller
public class QuartzUtil {

	public static List<String[]> DtbTblLst = new ArrayList<>();
	
	public static String[] pam;
	
	static {
		pam = new String[]{"kspt", "ksp_ksp_tsk"};
		DtbTblLst.add(pam);
	}
	
	
	
	@Autowired
	private QuartzMapper quartzMapper;
	
	
	@RequestMapping("/sche/do")
	public void generatePartTble() {
		
		for (String[] dtbTblArr : DtbTblLst) {
			String wDtbNam = dtbTblArr[0];
			String wTblNam = dtbTblArr[1];
			
			Map<String, Object> wPamMap = new HashMap<>();
			wPamMap.put("SCH_NAM", wDtbNam);
			wPamMap.put("TBL_NAM", wTblNam);
			List<Map<String, Object>> qryTblRowLst = quartzMapper.qryTblRow(wPamMap);
			if (qryTblRowLst != null && qryTblRowLst.size() > 0) {
				Map<String, Object> wQryTblRowMap = qryTblRowLst.get(0);
				String wCurTblNam = (String)wQryTblRowMap.get("TBL_NAM");
				String wCurRowSiz = (String)wQryTblRowMap.get("TBL_ROW");
				int wRowSizInt = Integer.parseInt(wCurRowSiz);
				if (wRowSizInt > 3) {
					String wNextTblSeq = wCurTblNam.substring(wCurTblNam.length()-2, wCurTblNam.length());
					int wNextTbl = Integer.parseInt(wNextTblSeq);
					String wNextTblStr = String.valueOf(wNextTbl);
					if (wNextTbl < 10) {
						wNextTblStr = "0" + wNextTblStr;
					}
					
					
				}
				
			}
		}
		
		
		
	}
	
	
}
